package demo1;

import java.util.Objects;

class Person{
    private String name;
    private int age;
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public int hashCode() {
        return Objects.hash(name,age);
    }
}
public class test1 {
    public static void main(String[] args) {
        Person p1 = new Person("owo",18);
        Person p2 = new Person("owo",18);
        int a = 1;
        int b = 1;
        System.out.println(a == b);//基本类型变量比较
        System.out.println(p1 == p2);//引用类型变量比较
        System.out.println(p1.equals(p2));//equals方法比较
        System.out.println(p1.hashCode());
        System.out.println(p2.hashCode());

    }
}
